package com.njxzc.igo.filter;


import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@WebFilter(servletNames = {"addAddress","loadAllCitys","loadAllProvince","loadAllRegions"
		,"LoadAllOrders","LoadOrderTypes","modifyOrderType","generateOrders","MyOrders","orderDetail",
		"topay","addproductType","AddNewProducts","DeleteProduct","loadproductstypes","addnewProducts","reloadgoods"
		,"deleteBatch","deleteInShoppingCart","modifyShoppingCart","reloadShoppingCart","Aloadalluserinfo",
		"modifyPassword","registAdmin","ALoadUserTypes","modifyUserTypes"},filterName="userPowerFilter") 
public class Filter3_LoginAndSourceFilter implements Filter {
	public void destroy() {

	}
	public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException {
		HttpServletRequest request = (HttpServletRequest)req;
		HttpServletResponse response= (HttpServletResponse)resp;
		HttpSession session = request.getSession();
		
		String uri = request.getRequestURI();
			if (session.getAttribute("u") == null) {
				request.setAttribute("page", uri);
				request.getRequestDispatcher("login.jsp").forward(request, response);
				return;
			}
		
			chain.doFilter(req, resp);
		}
		

	public void init(FilterConfig fConfig) throws ServletException {
	}

}
